#include <stdio.h>
#include "animal.h"
#include <stdarg.h>
#include <string.h>

static void animal_run(animal_t v)
{
    (void)v;
    printf("%s\n", __FUNCTION__);
}

static void set_animal_sex(animal_t v, char *sex)
{
    struct animal_pd_s     *pd = (struct animal_pd_s*)GET_PD(v, animal_s);

    memset(pd->sex, 0, sizeof(pd->sex));
    strncpy(pd->sex, sex, sizeof(pd->sex));
}

static void get_animal_sex(animal_t v)
{
    struct animal_pd_s     *pd = (struct animal_pd_s*)GET_PD(v, animal_s);

    printf("sex: %s\n", pd->sex);
}

void animal_init(animal_t v, int arg_num, ...)
{
    va_list     args;
    va_start(args, arg_num);
    //----------------------------------------------------

    v->animal_init = animal_init;
    v->animal_destroy = animal_destroy;

    v->run = animal_run;
    v->set_sex = set_animal_sex;
    v->get_sex = get_animal_sex;


    //----------------------------------------------------
    va_end(args);

}

void animal_destroy(animal_t v)
{
    (void)v;
    printf("%s\n", __FUNCTION__);
}
